package com.leetroll.api.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.leetroll.common.entity.User;
import com.leetroll.common.validator.annotation.NotBlank;
import com.leetroll.common.validator.annotation.Range;
import com.leetroll.common.validator.group.GetOne;
import com.leetroll.common.validator.group.Insert;
import com.leetroll.common.validator.group.Update;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * 用户UserVO
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class UserVO extends BaseVO {

    /**
     * 用户名
     */
    @NotBlank(groups = {Insert.class, GetOne.class})
    @Range(groups = {Insert.class, Update.class}, min = 5, max = 30)
    private String name;

    /**
     * 地址
     */
    private String address;

    /**
     * vip
     */
    private Boolean vip;


    /**
     * 背景图片
     */
    private String bgImg;

    /**
     * moto
     */
    private String moto;

    /**
     * 性别(1:男2:女)
     */
    private Integer gender;

    /**
     * 个人头像
     */
    private String avatar;
    /**
     * 状态
     */
    private String status;

    public static UserVO fromUser(User userInfo) {
        UserVO userVO = new UserVO();
        userVO.setId(userInfo.getId());
        userVO.setName(userInfo.getName());
        userVO.setGender(userInfo.getGender());
        userVO.setMoto(userInfo.getMoto());
        userVO.setVip(userInfo.getVip());
        userVO.setAddress(userInfo.getAddress());
        userVO.setAvatar(userInfo.getAvatar());
        userVO.setBgImg(userInfo.getBgImg());
        userVO.setStatus(userInfo.getStatus());
        return userVO;
    }
}
